﻿using System;
using System.Collections.Generic;
using System.Text;
using Kitware.VTK;

namespace Fu3DEngine
{
    public class CubeNode : CPNodeBase 
    {
       public CubeNode(CPCube ent,string id):base(id)
       {
           m_ent = ent;
         
       }

       CPCube m_ent;
       public override void Run()
       {
           base.Run();

           this.CreateCube(m_ent);
         

       }

       public override void ReLoad()
       {
           throw new NotImplementedException();
       }

       public void CreateCube(CPCube cy)
       {
           vtkCubeSource cylinder =  vtkCubeSource.New();


           cylinder.SetXLength(cy.dx);
           cylinder.SetYLength(cy.dy);
           cylinder.SetZLength(cy.dz);
           cylinder.SetCenter(0, cy.dz / 2, 0);


           vtkTransform tran = new vtkTransform();
           // tran.RotateX(90);


           vtkTransformFilter tf = new vtkTransformFilter();
           tf.SetInput(cylinder.GetOutput());
           tf.SetTransform(tran);





          
           //mapper.SetInput(cylinder.GetOutput());
           m_Poly.m_Mapper.SetInput(tf.GetPolyDataOutput());








           m_Poly.m_Actor.SetPosition(cy.x, cy.y, cy.z);

           m_Poly.m_Actor.GetProperty().SetAmbientColor(cy.m_color.R, cy.m_color.G, cy.m_color.B);
           m_Poly.m_Actor.GetProperty().SetDiffuseColor(cy.m_color.R, cy.m_color.G, cy.m_color.B);



           this.SParent.m_vtkRenderer.AddActor(m_Poly.m_Actor);

       }
    }
}
